package com.lyf.mapper.admin;

import com.github.pagehelper.Page;
import com.lyf.annotation.AutoFill;
import com.lyf.dto.DishPageQueryDTO;
import com.lyf.pojo.Dish;
import com.lyf.vo.DishItemVO;
import com.lyf.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import com.lyf.enumeration.OperationType;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    @Select("select * from dish where id = #{id}")
    DishVO selectById(Long id);

    List<Dish> selectByIds(List<Long> ids);

    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    void deleteBatch(List<Long> ids);
    @Select("select * from dish where category_id = #{categoryId} and status = 1")
    List<DishVO> list(Long categoryId);

    List<DishItemVO> getSetmealDIshItemsBySetmealId(Long id);
}
